%using Babel.Parser
%using Babel.ParserGenerator
%namespace StateMachine.Runtime.Compiler.Parser
%valuetype LexValue


%union {
    public string Value;
}

%token IDENTIFIER
%token COMMA
%token OPEN_PAREN
%token CLOSE_PAREN
%token OPEN_SET
%token CLOSE_SET
%token QUOTE
%token SYMBOL
%token EQUAL

%token	maxParseToken

%%

Automato
   : AutomatoName EQUAL AutomatoDescription { }
   ;
   
AutomatoName
   : IDENTIFIER { }
   ;

AutomatoDescription
   : OPEN_PAREN AutomatoStates COMMA AutomatoSymbols COMMA AutomatoTransitions COMMA AutomatoInitialState COMMA AutomatoFinalsStates CLOSE_PAREN { }
   ;
   
AutomatoStates
   : OPEN_SET States CLOSE_SET { }
   ;
   
States
   : State
   | State COMMA States { }
   ;
   
State
   : IDENTIFIER { }
   ;
   
AutomatoSymbols
   : OPEN_SET Symbols CLOSE_SET { }
   ;
   
Symbols
   : Symbol
   | Symbol COMMA Symbols { }
   ;

Symbol
   : QUOTE SYMBOL QUOTE { }
   ;
   
AutomatoTransitions
   : OPEN_SET Transitions CLOSE_SET { }
   ;
   
Transitions
   : Transition
   | Transition COMMA Transitions { }
   ;
   
Transition
   : OPEN_PAREN State COMMA Symbol COMMA States CLOSE_PAREN { /* validar se os estados existem, verificar se o simbolo existe */ }
   ;
   
AutomatoInitialState
   : State { /* validar se o estado existe */}
   ;
   
AutomatoFinalsStates
   : OPEN_SET States CLOSE_SET { /* verificar se os estados existem */ }
   ;
   
%%

/* ... */